package com.yifeng.repo.base.mdm.console.impl;

import com.yifeng.base.bds.api.dict.DictRestService;
import com.yifeng.base.bds.api.dict.dto.DictInfoDto;
import com.yifeng.repo.base.mdm.loader.annotation.MdmCache;
import com.yifeng.repo.base.params.ConsoleParam;
import com.yifeng.repo.base.security.proxy.CommonProxy;

import java.util.List;

/**
 * Created by daibing on 2024/3/1.
 */
@MdmCache(mdmTypeCode = "dict")
public class DictRestServiceImpl extends CommonProxy implements DictRestService {
    private final String mapping;

    public DictRestServiceImpl(ConsoleParam consoleParam) {
        super(consoleParam);
        this.mapping = "/yfcloud/bds/rest/DictRestService";
    }

    @Override
    public List<DictInfoDto> list(String typeCode) {
        String url = consoleParam.getUrl() + mapping + "/list";
        String queryParameters = buildSingleQueryParameters("typeCode", typeCode);
        String requestUrl = String.format("%s?%s", url, queryParameters);
        return this.doListCallByRpc(requestUrl, DictInfoDto.class);
    }
}
